package com.cipta.lomob.fragments;

import android.content.Context;
import android.graphics.Typeface;
import android.os.Bundle;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.ToggleButton;
import android.widget.TextView.BufferType;

import com.cipta.lomob.R;
import com.cipta.lomob.base.BaseFragment;

public class UploadVideoFragment extends BaseFragment{
	public static String FRAGMENT_TAG = "UploadVideoFragment";
	
	private Button btnSelectVideo, btnSubmitVideo;
	private EditText edtTitle;
	private Spinner spnCategory, spnRestriction;
	private ToggleButton tgglFb, tgglTwitter;
	private TextView txtUploadDesc;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		View view = inflater.inflate(R.layout.fragment_upload_video, container, false);
		initializeViews(view);
		
		getActivity().setTitle("UPLOAD VIDEO");
		
		return view;
	}
	
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onActivityCreated(savedInstanceState);
		
		initializeProcess();
		initializeActions();
	}
	
	@Override
	public void initializeViews(View view) {
		// TODO Auto-generated method stub
		super.initializeViews(view);
		
		btnSelectVideo = (Button)view.findViewById(R.id.btn_select_video);
		btnSubmitVideo = (Button)view.findViewById(R.id.btn_upload_video_submit);
		edtTitle = (EditText)view.findViewById(R.id.edt_upload_video_title);
		edtTitle.clearFocus();
		spnCategory = (Spinner)view.findViewById(R.id.spn_upload_video_category);
		spnRestriction = (Spinner)view.findViewById(R.id.spn_upload_video_restriction);
		tgglFb = (ToggleButton)view.findViewById(R.id.btn_tggl_upload_video_fb);
		tgglTwitter = (ToggleButton)view.findViewById(R.id.btn_tggl_upload_video_twitter);
		txtUploadDesc = (TextView)view.findViewById(R.id.txt_upload_video_desc);
	}
	
	@Override
	public void initializeProcess() {
		// TODO Auto-generated method stub
		super.initializeProcess();
		
		String categories[] = new String[]{
			"News", "Music", "Fun", "Movie", "Education", "School", "Dance", "Love"
		};
		
		String viewers[]= new String[]{
			"Public", "Private", "Follower"
		};
		
		ArrayAdapter<String> adapterCategory = new ArrayAdapter<String>(getActivity(),
				android.R.layout.simple_list_item_1,
				android.R.id.text1, 
				categories);
		ArrayAdapter<String> adapterViewer = new ArrayAdapter<String>(getActivity(),
				android.R.layout.simple_list_item_1,
				android.R.id.text1, 
				viewers);
		
		spnCategory.setAdapter(adapterCategory);
		spnRestriction.setAdapter(adapterViewer);
		
		String desc = "<i>By submitting your videos to Lomob, you acknowledge that you " +
				"agree to Lomob's <font color='#a9d36e'>Term of Service</font></i>";
		txtUploadDesc.setText(Html.fromHtml(desc), BufferType.SPANNABLE);
		txtUploadDesc.setTypeface(null, Typeface.ITALIC);
	}
	
	@Override
	public void initializeActions() {
		// TODO Auto-generated method stub
		super.initializeActions();
		
		btnSelectVideo.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				
			}
		});
		
		btnSubmitVideo.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				
			}
		});
		
		txtUploadDesc.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				
			}
		});
	}
}
